package com.uam.core.lk.utils;

/**
 * @author 祝展
 * @version 1.0
 * @description
 * @Date 2019/10/30 09:46
 **/
public class ResponseResult<T> {

    public static final int ERROR = 1;
    public static final int SUCCESS = 0;
    public static final Long COSTTIME = 0L;

    private int code;
    private String msg;
    private Long cost;
    private T data;
    private String traceId;

    public ResponseResult() {
        this.code = SUCCESS;
        this.cost = COSTTIME;
        this.msg = "success";
    }

    public ResponseResult(T data) {
        this.code = SUCCESS;
        this.cost = COSTTIME;
        this.data = data;
    }

    public ResponseResult(ResponseResult result) {
        this.code = result.getCode();
        this.cost = result.getCost();
        this.data = (T) result.getData();
        this.msg = result.getMsg();
    }

    public ResponseResult(ErrorInterface errorInterface) {
        this.code = errorInterface.getErrorCode();
        this.msg = errorInterface.getErrorMessage();
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Long getCost() {
        return cost;
    }

    public void setCost(Long cost) {
        this.cost = cost;
    }

    public String getTraceId() {
        return traceId;
    }

    public void setTraceId(String traceId) {
        this.traceId = traceId;
    }
}
